package com.jlf.core.server.entity;

import lombok.Getter;
import lombok.Setter;

import java.util.Collection;

/**
 * 数组输出结果的封装
 *
 * @author wujr
 * 2021/1/3
 * @version 1.0
 * 变更历史
 * [wujr 2021/1/3 1.0 新增]
 */
@Getter
@Setter
public class ListWrapper<T> {
    private Integer total;
    private Collection<T> record;

    @SuppressWarnings("unchecked")
    public void record(Collection<?> record){
        this.record = (Collection<T>)record;
    }

    public ListWrapper(Collection<T> record) {
        this.total = record.size();
        this.record = record;
    }
    public ListWrapper(Integer total, Collection<T> record) {
        this.total = total;
        this.record = record;
    }

    public static <T> ListWrapper<T> empty(){
        return new ListWrapper<>(0, null);
    }
    public static <T> ListWrapper<T> empty(int total){
        return new ListWrapper<>(total, null);
    }
}
